package com.ruoyi.web.controller.banquet;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.banquet.BanquetSupplier;
import com.ruoyi.system.service.banquet.IBanquetSupplierService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 上门宴资源服务商Controller
 * 
 * @author ruoyi
 * @date 2022-03-21
 */
@RestController
@RequestMapping("/system/supplier")
public class BanquetSupplierController extends BaseController
{
    @Autowired
    private IBanquetSupplierService banquetSupplierService;

    /**
     * 查询上门宴资源服务商列表
     */
    @PreAuthorize("@ss.hasPermi('system:supplier:list')")
    @GetMapping("/list")
    public TableDataInfo list(BanquetSupplier banquetSupplier)
    {
        startPage();
        List<BanquetSupplier> list = banquetSupplierService.selectBanquetSupplierList(banquetSupplier);
        return getDataTable(list);
    }

    /**
     * 导出上门宴资源服务商列表
     */
    @PreAuthorize("@ss.hasPermi('system:supplier:export')")
    @Log(title = "上门宴资源服务商", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BanquetSupplier banquetSupplier)
    {
        List<BanquetSupplier> list = banquetSupplierService.selectBanquetSupplierList(banquetSupplier);
        ExcelUtil<BanquetSupplier> util = new ExcelUtil<BanquetSupplier>(BanquetSupplier.class);
        util.exportExcel(response, list, "上门宴资源服务商数据");
    }

    /**
     * 获取上门宴资源服务商详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:supplier:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(banquetSupplierService.selectBanquetSupplierById(id));
    }

    /**
     * 新增上门宴资源服务商
     */
    @PreAuthorize("@ss.hasPermi('system:supplier:add')")
    @Log(title = "上门宴资源服务商", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BanquetSupplier banquetSupplier)
    {
        return toAjax(banquetSupplierService.insertBanquetSupplier(banquetSupplier));
    }

    /**
     * 修改上门宴资源服务商
     */
    @PreAuthorize("@ss.hasPermi('system:supplier:edit')")
    @Log(title = "上门宴资源服务商", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BanquetSupplier banquetSupplier)
    {
        return toAjax(banquetSupplierService.updateBanquetSupplier(banquetSupplier));
    }

    /**
     * 删除上门宴资源服务商
     */
    @PreAuthorize("@ss.hasPermi('system:supplier:remove')")
    @Log(title = "上门宴资源服务商", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(banquetSupplierService.deleteBanquetSupplierByIds(ids));
    }
}
